/*
 * @Author: zhouhai 497675647@qq.com
 * @Date: 2023-04-23 15:51:51
 * @LastEditors: zhouhai 497675647@qq.com
 * @LastEditTime: 2023-04-25 16:42:37
 */
import cache from '@/plugins/cache';
import { makeAutoObservable } from 'mobx';
import { themToken } from './ThemeToekn';
import { AliasToken } from 'antd/es/theme/interface';

class LayoutColorStore {
	themeToke: Partial<AliasToken> = cache.session.getJSON('themeToke') || themToken;
    mainValue: string = cache.session.getJSON('mainValue') || 'default';
    formSize: string = cache.session.get('formSize') || 'default';

	constructor() {
		makeAutoObservable(this);
	}

    setThemToken = (_config: Partial<AliasToken> ) => {
        this.themeToke = {...this.themeToke,..._config}
    } 

    setThemTokenAndCache = (_config: Partial<AliasToken> ) => {
        const newthemetoken = {...this.themeToke,..._config};
        this.themeToke = newthemetoken
        cache.session.setJSON('themeToke', newthemetoken)
    }

    setMainValue = (_mainValue: string) => {
        this.mainValue = _mainValue;
    }

    setMainValueAndCache = (_mainValue: string) => {
        this.mainValue = _mainValue;
        cache.session.setJSON('mainValue',_mainValue)
    }

    setFormSize = (_formSize: string) => {
        this.formSize = _formSize;
    }

    setFormSizeAndCache = (_formSize: string) => {
        this.formSize = _formSize;
        cache.session.set('formSize',_formSize)
    }

    resetThemToken = () =>{
        this.themeToke = cache.session.getJSON('themeToke') || themToken;
        this.mainValue = cache.session.getJSON('mainValue') || 'default';
        this.formSize = cache.session.get('formSize') || 'default';
    }



}
export { LayoutColorStore };